package cz.acies.genea.data.persist;

import java.util.Map;

import cz.acies.data.persist.ModelObject;

/**
 * TYPE         EXT       DESCRIPT</br>
 * ---------------------------------</br>
 * PARENT   &&  FATHER  = objectId ukazuje sosbu partnera</br>
 * PARENT   &&  MOTHER  = objectId ukazuje sosbu partnera</br>
 * PARENT   &&  FAMILY  = objectId ukazuje rodinu rodičů</br>
 * PARTNER  &&  PERSON  = objectId ukazuje sosbu partnera</br>
 * PARTNER  &&  FAMILY  = objectId ukazuje rodinu s partnerem</br>
 * CHILD    &&  PERSON	= objectId ukazuje na dítě osoby</br>
 * CHILD    &&  FAMILY  = objectId ukazuje na dítě rodiny</br>
 */
public class GedPersonBinding extends ModelObject implements Cloneable
{
	private static final long serialVersionUID = -8726444820722252144L;

	private String objectId;
	private String connectId;
	private String bindingType;
	private String extend;
	
	public GedPersonBinding() {
		this(null, null, null, null, null);
	}

	public GedPersonBinding(String id) {
		this(id, null, null, null, null);
	}

	public GedPersonBinding(String id, Map<String, Object> data) {
		this(id, 
			(String) data.get("objectId"), 
			(String) data.get("connectId"), 
			(String) data.get("bindingType"),
			(String) data.get("extend")
		);
	}
	
	public GedPersonBinding(String id, String objectId, String connectId, String bindingType, String extend) {
		this.setId((id != null) ? id : "");
		this.setObjectId((objectId != null) ? objectId : "");
		this.setConnectId((connectId != null) ? connectId : "");
		this.setBindingType((bindingType != null) ? bindingType : "UNKNOW");
		this.setExtend((extend != null) ? extend : ""); 
	}
	
	public String getObjectId() {
		return objectId;
	}
	
	public boolean hasObjectId() {
		return (objectId != null && objectId.length() > 0);
	}

	public void setObjectId(String objectId) {
		this.objectId = objectId;
	}
	
	public String getConnectId() {
		return connectId;
	}
	
	public boolean hasConnectId() {
		return (connectId != null && connectId.length() > 0);
	}
	
	public void setConnectId(String connectId) {
		this.connectId = connectId;
	}

	public String getBindingType() {
		return bindingType;
	}
	
	public boolean hasBindingType() {
		return (bindingType != null && bindingType.length() > 0);
	}

	public void setBindingType(String bindingType) {
		this.bindingType = bindingType;
	}

	public String getExtend() {
		return extend;
	}

	public boolean hasExtend() {
		return (extend != null && extend.length() > 0);
	}

	public void setExtend(String extend) {
		this.extend = extend;
	}
}
